#include<iostream>
#include<unordered_map>

using namespace std;

const int N = 1e6 + 10;
int a[N];
unordered_map<int,int>mp;
int t , n;

int main()
{
    cin >> t;
    while(t--)
    {
        cin >> n;
        for(int i = 1;i <= n;i ++) cin >> a[i];
        int left = 1 , right = 1 ,  ret  = 0;
        while(right <= n)
        {
            mp[a[right]]++;
            while(mp[a[right]] > 1)
            {
                mp[a[left]]--;
                left++;
            }
            ret = max(ret , right - left + 1);
            right ++;
        }
        cout << ret << endl;
    }
    return 0;
}